<?php
	header("HTTP/1.1 200 OK");
	header("Content-Type: text/html; charset=UTF-8");

	require_once('shared.php');

	$res = $routes->Check($ruri);

	$controllerClass = $res['controller'];
	$controllerFile = 'controller/'.$controllerClass.'.php';
	$controllerError = !file_exists($controllerFile);
	$controllerAction = $res['action'];

	$controller = null;
	if(!$controllerError){
		require_once($controllerFile);
		$controller = new $controllerClass($res);
		$controllerError = !method_exists($controller, $controllerAction);
	}

	if($controllerError) {
		include_once('controller/Main.php');
		$controller = new Main($res);
		$controllerAction = 'UnknownRoute';
	}

	$controller->$controllerAction();
	$controller->Headers();
	echo $controller;

?>